<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>弓友之家</title>
    <link rel="stylesheet" href="css/mui.css" />
    <link rel="stylesheet" href="fonts/iconfont.css" />
    <link rel="stylesheet" href="css/style.css" />
</head>
<body>
	<div class="index-serach mui-clearfix mui-bar-nav">
		<form class="mui-pull-left">
			<input type="text" id="keys" placeholder="输入您想要查找的内容" />
			<select id="type">
				<option data-type="1">商品</option>
				<option data-type="2">会员</option>
				<option data-type="3">文章</option>
			</select>
			<button type="button" onclick="search()" class="iconfont icon-sousuo"></button>
		</form>
		<span onclick="window.location.href='chat.html'" class="mui-pull-right on"><i class="iconfont icon-xiaoxi"></i></span>
	</div>
	<div class="mui-content">
		<!--轮播图-->
		<div id="slider" class="mui-slider" >
			<div class="mui-slider-group mui-slider-loop">
				
			</div>
			<div class="mui-slider-indicator">
				
			</div>
			
			<!--赛事信息-->
			<div class="txtScroll-top">
				<div class="bd">
					<ul>
					</ul>
				</div>
			</div>
		</div>
		<!--导航-->
		<div class="index-nav mui-clearfix">
			<a data-href="integralrank.html">
				<img src="images/nav1.png"/>
				<p>积分排行</p>
			</a>
			<a data-href="game.html">
				<img src="images/nav2.png"/>
				<p>赛事回顾</p>
			</a>
			<a data-href="searchmember.html">
				<img src="images/nav3.png"/>
				<p>会员查询</p>
			</a>
			<a data-href="partner.html">
				<img src="images/nav6.png"/>
				<p>合作单位</p>
			</a>
			<a data-href="sign.html" class="sign" data-status="">
				<img src="images/nav7.png"/>
				<p>报名入口</p>
			</a>
		</div>
		<!--经验聊天-->
		<div class="index-experience">
			<div class="head1 mui-clearfix">
				经验交流
				<a data-href="experience.html">查看更多<i class="iconfont icon-lunbofanyeanniu_you"></i></a>
			</div>
			<div class="mui-clearfix content">
				
			</div>
		</div>
		<!--推荐商品-->
		<div class="index-goods">
			<div class="head1 mui-clearfix">
				推荐商品
				<a data-href="shop.html">查看更多<i class="iconfont icon-lunbofanyeanniu_you"></i></a>
			</div>
			<div class="mui-clearfix content">
				
			</div>
		</div>
	</div>
	<br /><br /><br />
	<!--首次登录-->
	<div class="first-login mui-hidden">
		<div class="text">恭喜您今天首次登录<br/>获得50积分</div>
		<button type="button">收入囊中</button>
	</div>
	<!--兑换弹出框-->
	<div class="buy-box mui-hidden">
		<div class="text">您是想如何购买商品？</div>
		<div class="mui-row">
			<div class="mui-col-xs-6">
				<button type="button" data-gid="" class="dhbtn">立即兑换</button>
			</div>
			<div class="mui-col-xs-6">
				<button type="button" data-tburl="" class="dhbtn1">立即购买</button>
			</div>
		</div>
	</div>
	
	<!--底部导航-->
	<footer class="mui-row">
		<div class="mui-col-xs-3 on"><a data-href="index.html">
			<img src="images/f1.png" class="old" />
			<img src="images/f1_on.png" class="hover" />
			<p>首页</p>
		</a></div>
		<div class="mui-col-xs-3"><a data-href="shop.html">
			<img src="images/f2.png" class="old" />
			<img src="images/f2_on.png" class="hover" />
			<p>商城</p> 
		</a></div>
		<div class="mui-col-xs-3"><a data-href="experience.html">
			<img src="images/f3.png" class="old" />
			<img src="images/f3_on.png" class="hover" />
			<p>弓略</p>
		</a></div>
		<div class="mui-col-xs-3"><a data-href="chat.html">
			<img src="images/f3.png" class="old" />
			<img src="images/f3_on.png" class="hover" />
			<p>在线聊天</p>
		</a></div>
		<div class="mui-col-xs-3"><a data-href="user.html">
			<img src="images/f4.png" class="old" />
			<img src="images/f4_on.png" class="hover" />
			<p>个人中心</p>
		</a></div>
	</footer>
	 
	 <!--版本-->
	<div id="vesion" class="mui-hidden">
		<div class="img"><img src="images/vesion.jpg"/></div>
		<div class="mui-row">
			<div class="mui-col-xs-6 confirm">
				<button type="button">立即更新</button>
			</div>
			<div class="mui-col-xs-6 cancle">
				<button type="button">暂不更新</button>
			</div>
		</div>
	</div>
	<script type="text/javascript" src="js/mui.min.js" ></script>
	<script type="text/javascript" src="js/jquery-1.8.3.min.js" ></script>
	<script type="text/javascript" src="js/jquery.SuperSlide.2.1.1.js" ></script>
	<script type="text/javascript" src="js/common.js" ></script>
	<script type="text/javascript" charset="utf-8">
      	mui.init(); 
      	mui.plusReady(function(){
      	}) 
      	//轮播图 
      	mui.ajax(H_SRC+'/amier/index/index',{
			data:{},
			dataType:'json', 
			type:'post',
			timeout:10000,             
			success:function(data){
				var dataurl=data.data;
				
				if(data.code == 1){
					//轮播图
					var lb="",dot="";
					lb+='<div class="mui-slider-item mui-slider-item-duplicate"><img src="'+H_SRC+''+dataurl.imgs[dataurl.imgs.length-1].img_url+'"></div>'
					for(var i=0;i<dataurl.imgs.length;i++){
						lb+='<div class="mui-slider-item"><img src="'+H_SRC+''+dataurl.imgs[i].img_url+'" /></div>';
						dot+='<div class="mui-indicator"></div>';   
					}
					lb+='<div class="mui-slider-item mui-slider-item-duplicate"><img src="'+H_SRC+''+dataurl.imgs[0].img_url+'"></div>';
					$(".mui-slider-group").html(lb);
					$(".mui-slider-indicator").html(dot);
					$(".sign").attr("data-status",dataurl.match_status);
					var href="";
					$(".mui-slider-group").on("tap","a",function(){
						gid=$(this).attr("data-href");
						mui.openWindow({
							url:'goods-list-page.html',
							id:'goods-list-page.html',
							createNew:true,
							show: {
								autoShow: true,
								aniShow: 'slide-in-right',
								duration: 200,
							},
							extras:{
								gid:gid
							}
						});
					})
					var slider = mui("#slider");
      				slider.slider({interval: 4000}); 
      				//赛事信息
      				var ss="";
      				for(var i=0;i<dataurl.match.length;i++){
						ss+='<li class="mui-ellipsis" data-href="notice.html"><a>'+dataurl.match[i].title+'</a></li>';
					}
      				$(".txtScroll-top .bd ul").html(ss);
      				jQuery(".txtScroll-top").slide({titCell:".hd ul",mainCell:".bd ul",autoPage:true,effect:"top",autoPlay:true,delayTime:1000,pnLoop:false});
					//经验交流
					var jy="";
					for(var i=0;i<dataurl.exchange.length;i++){
						jy+='<div class="one"><a data-id='+dataurl.exchange[i].id+'>';
						jy+='<div class="img" style="background-image: url('+H_SRC+''+dataurl.exchange[i].thumb+');"></div>';
						jy+='<h4><span>帖子</span>'+dataurl.exchange[i].title+'</h4>';
						jy+='</a></div>'; 
					}
					$(".index-experience .content").html(jy);
					$(".index-experience .content").on("tap","a",function(){
						if(token==null||token=="null"){
							mui.openWindow({
								url:'login.html',
								id:'login.html',
								createNew:true,
								show: {
									autoShow: true,
									aniShow: 'slide-in-right',
									duration: 200
								}
							});
						}else{
							var nid=$(this).attr("data-id");
							mui.openWindow({
								url:'experience-page.html',
								id:'experience-page.html',
								createNew:true,
								extras:{
									nid:nid
								},
								show: {
									autoShow: true,
									aniShow: 'slide-in-right',
									duration: 200
								} 
							});
						}
					})
					//推荐商品
					var goods="";
					for(var i=0;i<dataurl.goods.length;i++){
						goods+='<div class="one" data-id="'+dataurl.goods[i].id+'" data-taobao="'+dataurl.goods[i].taobao_url+'"><a class="img"><img src="'+H_SRC+''+dataurl.goods[i].img+'"/></a>';
						goods+='<div class="text"><h4 class="mui-ellipsis"><a data-id="'+dataurl.goods[i].id+'">'+dataurl.goods[i].goodsName+'</a></h4>';
						if(dataurl.goods[i].isShipping==1){
							var by="<i>包邮</i>";
						}else{
							var by=""
						}
						goods+='<h5 class="mui-clearfix"><span>￥'+parseInt(dataurl.goods[i].price)+'</span>'+by+'<button type="button">立即兑换</button></h5>';
						goods+='</div></div>'; 
					}
					$(".index-goods .content").html(goods);
					
					var newvesion=data.edition.edition;
					var wgtVer=plus.runtime.version; //获取本地版本号
					var phonetype=navigator.userAgent.toLowerCase();  //获取手机型号
					if(wgtVer!=newvesion){ //对比下载
						$("#vesion").removeClass("mui-hidden");
						$("#vesion .confirm").on("tap",function(){
							if(/iphone|ipad|ipod/.test(phonetype)) {     
								$("#vesion").addClass("mui-hidden");
					            var url='https://itunes.apple.com/cn/app/%E5%BC%93%E5%8F%8B%E4%B9%8B%E5%AE%B6/id1331275646?mt=8'; 
								plus.runtime.openURL(url);
					      }else if(/android/.test(phonetype)){ 
					        	var url="http://www.amierzhandui.com/data/ame.apk"; 
								var dtask = plus.downloader.createDownload( url, {}, function ( d, status ) {
								    if ( status == 200 ) { // 下载成功
								        mui.toast("请稍等，正在下载");
								        plus.runtime.install(d.filename);
								    } else {
								        mui.alert( "Download failed: " + status); 
								    }  
								});
								dtask.start(); 
					        }
						})
					}
				}else{
					mui.toast(data.msg);
				}
			},
			error:function(){
				
			}
		}) 
      	$(".index-nav").on("tap","a",function(){
      		if(token==null||token=="null"){
				mui.openWindow({
					url:'login.html',
					id:'login.html',
					createNew:true,
					show: {
						autoShow: true,
						aniShow: 'slide-in-right',
						duration: 200
					}
				});
			}else{
				var href=$(this).attr("data-href");
				if(href=="sign.html"){
					if($(".sign").attr("data-status")==0){
						mui.alert("您好，目前暂无比赛,谢谢您的关注。","比赛提醒");
					}else{
						mui.openWindow({
							url:href,
							id:href,
							createNew:true,
							show: {
								autoShow: true,
								aniShow: 'slide-in-right',
								duration: 200
							}
						});
					}
				}else{
					mui.openWindow({
						url:href,
						id:href,
						createNew:true,
						show: {
							autoShow: true,
							aniShow: 'slide-in-right',
							duration: 200
						}
					});
				}
			}
      	})
      	
      	$(".head1").on("tap","a",function(){ 
      		if(token==null||token=="null"){
				mui.openWindow({
					url:'login.html',
					id:'login.html',
					createNew:true,
					show: {
						autoShow: true,
						aniShow: 'slide-in-right',
						duration: 200
					}
				});
			}else{
				var href=$(this).attr("data-href");
	      		mui.openWindow({
					url:href,
					id:href,
					createNew:true,
					show: {
						autoShow: true,
						aniShow: 'slide-in-right',
						duration: 200
					}
				});
			}
      	})
      	
      	$(".index-goods .content").on("tap",".one",function(){
      		if(token==null||token=="null"){
				mui.openWindow({
					url:'login.html',
					id:'login.html',
					createNew:true,
					show: {
						autoShow: true,
						aniShow: 'slide-in-right',
						duration: 200
					}
				});
			}else{
				var gid=$(this).attr("data-id");
//	      		var tburl=$(this).attr("data-taobao");
//	      		$(".dhbtn").attr("data-gid",gid);
//	      		$(".dhbtn1").attr("data-tburl",tburl);
//	      		mask.show();
//	      		$(".buy-box").removeClass("mui-hidden");
				mui.openWindow({
					url:'goods-list-page.html',
					id:'goods-list-page.html',
					createNew:true,
					show: {
						autoShow: true,
						aniShow: 'slide-in-right',
						duration: 200,
					},
					extras:{
						gid:gid
					}
				});
			}
      	})
      	$(".txtScroll-top .bd ul").on("tap","li",function(){
      		if(token==null||token=="null"){
				mui.openWindow({
					url:'login.html',
					id:'login.html',
					createNew:true,
					show: {
						autoShow: true,
						aniShow: 'slide-in-right',
						duration: 200
					}
				});
			}else{
				var href=$(this).attr("data-href");
	      		mui.openWindow({
					url:href,
					id:href,
					createNew:true,
					show: {
						autoShow: true,
						aniShow: 'slide-in-right',
						duration: 200
					}
				});
			}
      	})
      	
      	$(".dhbtn").on("tap",function(){ 
      		if(token==null||token=="null"){
				mui.openWindow({
					url:'login.html',
					id:'login.html',
					createNew:true,
					show: {
						autoShow: true,
						aniShow: 'slide-in-right',
						duration: 200
					}
				});
			}else{
				var gid=$(this).attr("data-gid");
	      		mui.openWindow({
					url:'dhaddress.html',
					id:'dhaddress.html',
					createNew:true,
					extras:{
						gid:gid
					},
					show: {
						autoShow: true,
						aniShow: 'slide-in-right',
						duration: 200
					}
				});
			}
      	})
  
      	function search(){
      		if(token==null||token=="null"){
				mui.openWindow({
					url:'login.html',
					id:'login.html',
					createNew:true,
					show: {
						autoShow: true,
						aniShow: 'slide-in-right',
						duration: 200
					}
				});
			}else{
				var keys=$("#keys").val();
	      		if(keys==""){
	      			mui.toast("搜索内容不能为空");
	      			return false;
	      		}
	      		var type=$("#type").children("option:selected").attr("data-type");
	      		mui.openWindow({
					url:'search.html',
					id:'search.html',
					createNew:true,
					extras:{
						keys:keys,
						type:type
					},
					show: {
						autoShow: true,
						aniShow: 'slide-in-right',
						duration: 200
					}
				});
			}
      	}
      	$(".dhbtn1").on("tap",function(){
      		if(token==null||token=="null"){
				mui.openWindow({
					url:'login.html',
					id:'login.html',
					createNew:true,
					show: {
						autoShow: true,
						aniShow: 'slide-in-right',
						duration: 200
					}
				});
			}else{
				var link=$(this).attr("data-tburl");
	      		mui.openWindow({
					url:link,
					id:link,
					createNew:true, 
					show: {
						autoShow: true,
						aniShow: 'slide-in-right',
						duration: 200
					}
				});
			}
      	})
      	
      	var mask=mui.createMask(callback);
      	function callback(){
      		$(".first-login").addClass("mui-hidden");
      		$(".buy-box").addClass("mui-hidden");
      	}
      	
      	$("#vesion .cancle").on("tap",function(){
			$("#vesion").addClass("mui-hidden");
		})
    </script>
</body>
</html>